package net.qhzw.vip.qiyu.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import net.qhzw.vip.qiyu.model.SendSmsParam;
import net.qhzw.vip.qiyu.result.JsonResult;
import net.qhzw.vip.qiyu.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("sms")
@Api(tags="发送验证码接口")
public class SmsController {

    @Autowired
    private SmsService smsService;

    @PostMapping("/send")
    @ApiOperation(value = "发送短信")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sms", value = "短信的json数据")
    })
    public JsonResult sendMsg(@RequestBody SendSmsParam sendSmsParam) {
        boolean isOk = smsService.sendTo(sendSmsParam);
        if (isOk) {
            return JsonResult.ok();
        }
        return JsonResult.fail("发送失败");
    }


}
